package cn.js.servlet;

import cn.js.dao.powerbattery.SysPowerbatteryMapper;
import cn.js.utils.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/PowerBatteryDeleteServlet")
public class PowerBatteryDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");

        int id = Integer.parseInt(request.getParameter("id"));
        SqlSession sqlSession = MyBatisUtil.createSqlSession();
        int row= sqlSession.getMapper(SysPowerbatteryMapper.class).delete(id);
        sqlSession.commit();
        PrintWriter out  = response.getWriter();
        out.print(row);

        out.flush();
        out.close();
        MyBatisUtil.createSqlSession();



    }
}
